<?php

/**
 * This is the model class for table "d_valas".
 *
 * The followings are the available columns in table 'd_valas':
 * @property string $THANG
 * @property string $KDJENDOK
 * @property string $KDSATKER
 * @property string $KDDEPT
 * @property string $KDUNIT
 * @property string $KDDEKON
 * @property string $REGISTER
 * @property string $KDVALAS
 * @property double $NILAIVALAS
 * @property double $EKUIUSD
 * @property double $EKUIRPH
 * @property integer $ID
 */
class DValas extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return DValas the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'd_valas';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NILAIVALAS, EKUIUSD, EKUIRPH', 'numerical'),
			array('THANG', 'length', 'max'=>4),
			array('KDJENDOK, KDUNIT', 'length', 'max'=>2),
			array('KDSATKER', 'length', 'max'=>6),
			array('KDDEPT, KDVALAS', 'length', 'max'=>3),
			array('KDDEKON', 'length', 'max'=>1),
			array('REGISTER', 'length', 'max'=>8),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('THANG, KDJENDOK, KDSATKER, KDDEPT, KDUNIT, KDDEKON, REGISTER, KDVALAS, NILAIVALAS, EKUIUSD, EKUIRPH, ID', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    'satker' => array(self::BELONGS_TO, 'TSatker', 'KDSATKER'),
                    'dept' => array(self::BELONGS_TO, 'TDept', 'KDDEPT'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'THANG' => 'Thang',
			'KDJENDOK' => 'Kdjendok',
			'KDSATKER' => 'Satker',
			'KDDEPT' => 'Departemen',
			'KDUNIT' => 'Kdunit',
			'KDDEKON' => 'Kddekon',
			'REGISTER' => 'Register',
			'KDVALAS' => 'Kdvalas',
			'NILAIVALAS' => 'Nilaivalas',
			'EKUIUSD' => 'Ekuiusd',
			'EKUIRPH' => 'Ekuirph',
			'ID' => 'ID',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('THANG',$this->THANG,true);
		$criteria->compare('KDJENDOK',$this->KDJENDOK,true);
		$criteria->compare('KDSATKER',$this->KDSATKER,true);
		$criteria->compare('KDDEPT',$this->KDDEPT,true);
		$criteria->compare('KDUNIT',$this->KDUNIT,true);
		$criteria->compare('KDDEKON',$this->KDDEKON,true);
		$criteria->compare('REGISTER',$this->REGISTER,true);
		$criteria->compare('KDVALAS',$this->KDVALAS,true);
		$criteria->compare('NILAIVALAS',$this->NILAIVALAS);
		$criteria->compare('EKUIUSD',$this->EKUIUSD);
		$criteria->compare('EKUIRPH',$this->EKUIRPH);
		$criteria->compare('ID',$this->ID);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}